home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 46 / Amiga Format CD46 (1999-10-20)(Future Publishing)(GB)[!][issue 1999-12].iso / -in_the_mag- / reader_requests / scilab / demos / lqg / lqg2.dem
Text File  |  1999-09-16  |  1KB  |  24 lines

  1. s=poly(0,'s');
  2. Plant=[1/(s+1),s/(s-1)^2;(s-1)*s/(s^2-3*s+2),2/s];
  3. Plant=syslin('c',[1/(s+1)*s/(s-1)^2]);     //Nominal Plant
  4. P22=tf2ss(Plant);    //...in state-space form
  5. [ny,nu,nx]=size(P22);
  6. rand('seed',0);rand('normal');
  7. bigQ=rand(nx+nu,nx+nu);bigQ=bigQ*bigQ';
  8. bigR=rand(nx+ny,nx+ny);bigR=bigR*bigR';  //random weighting matrices
  9. [Plqg,r]=lqg2stan(P22,bigQ,bigR);     //LQG pb as a standard problem
  10. Klqg=lqg(Plqg,r);          //Controller
  11. spec(h_cl(Plqg,r,Klqg))    //Check internal stability
  12. [Slqg,Rlqg,Tlqg]=sensi(P22,Klqg);  //Sensitivity functions
  13. frq=logspace(-3,3);     //10^-3  to 10^3 
  14. y=svplot(Slqg);       //Computes singular values;
  15. xbasc();gainplot(frq,y)   //Plot sing. values
  16. w1=1/(s+1);
  17. w2=100;
  18. [Ptmp,r]=augment(P22,'SR');         //"S/KS" problem
  19. Pinf=sysdiag(w1,w2,1)*Ptmp;        //Weighting functions
  20. [Kinf,ro]=h_inf(Pinf,r,0,0.1,50);
  21. [Sinf,Rinf,Tinf]=sensi(P22,Kinf);  //Sensitivity functions
  22. y=svplot(Sinf);       //Computes singular values;
  23. xset("window",1);xselect();gainplot(frq,y)   //Plot sing. values
  24.